<template>
  <div>
    <div style="width: 100%;height:150px;margin-top: 50px;text-align: center;">
      Logo
    </div>
    <div style="width: 200px;margin:auto;">
      <a-form-model layout="inline" style="text-align: center;" :model="formInline" @submit="handleSubmit" @submit.native.prevent>
        <a-form-model-item>
          <a-input v-model="formInline.username" placeholder="Username">
            <a-icon slot="prefix" type="user" style="color:rgba(0,0,0,.25)" />
          </a-input>
        </a-form-model-item>
        <a-form-model-item>
          <a-input v-model="formInline.password" type="password" placeholder="Password">
            <a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)" />
          </a-input>
        </a-form-model-item>
        <a-form-model-item>
          <a-button
            type="primary"
            html-type="submit"
            :disabled="formInline.username === '' || formInline.password === ''"
          >
            Log in
          </a-button>
        </a-form-model-item>
      </a-form-model>
    </div>
  </div>
</template>

<script>

    import { getAction,postAction } from '@/api/dl'


    import Vue from 'vue'

    export default {
        data() {
            return {
                formInline: {
                    username: '',
                    password: '',
                },
            };
        },
        methods: {
            handleSubmit(e) {
                postAction("noteUser/login2",this.formInline).then(res=>{
                  // console.log("请求成功 ",res);
                    if(res.code=="200"||res.code=="0"){
                        this.$message.success('欢迎回来')
                        //保存token
                        Vue.ls.set("USER_INFO", res.data.userInfo, 7 * 24 * 60 * 60 * 1000)
                        Vue.ls.set("ACCESS_TOKEN",res.data.token);

                        // store.commit('SET_INFO', res.result.userInfo)
                        //退出删除remove
                        // Vue.ls.remove(ACCESS_TOKEN)
                        //跳转页面
                        this.$router.push({path:"/note/index"});
                    }else{
                        this.$message.error(res.tip);
                    }

                }).catch(error=>{

                })

            },
        },
    };
</script>
